<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>
	
	<body>
		<div class="breadcrumbs" id="breadcrumbs">
	
			<ul class="breadcrumb">
				<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
				<li>用户中心</li>
				<li>角色管理</li>
				<li class="active">添加角色</li>
			</ul>
			
		</div>
		
		<div class="page-content">
			<div class="page-header">
				<h1>角色管理
					<small>
					<i class="icon-double-angle-right"></i>
					添加角色	
					</small>					
				</h1>			
			</div> 
			<div class="row">
				<div class="col-xs-12">
					<form class="form-horizontal" onsubmit="return sysRoleInfoAdd();" role="form" id="sysRoleAddForm" name="sysRoleAddForm" method="post">
						
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">角色名称</label>
							<div class="col-sm-9">
								<input type="text" id="roleName"  name="roleName" value="" placeholder="角色名称"  required class="col-xs-10 col-sm-5" size="50" />
							</div>
						</div>	
					
						<div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<button class="btn btn-info" type="submit">
									<i class="icon-ok bigger-110"></i>提交
								</button>
							</div>
						</div>
						
					</form>		
				</div>
							
			</div>
		</div>
		
		<script type="text/javascript">
			function sysRoleInfoAdd() {
				//if($("#sysRoleAddForm").validationEngine("validate")){
				if (true) {
					//alert('dd');
					var datastr = new Object();
	    			datastr.roleName = $('#roleName').val();
					var result = true;
					$.ajax({
	    		        async: true,
	    		        type:"POST",
	    		        data:JSON.stringify(datastr),
	    		        url: "${ctx}/sys/role/add?&mid="+Math.random(),
	    		        dataType: "json",
	    		        headers : {  
	                        'Content-Type' : 'application/json;charset=utf-8'  
	                    },
	                    success : function(data) {
	                		if (data != undefined && data.status != undefined
	                				&& data.status.trim() == '0') {
	                			result = true;
	                			alert("保存成功！");
	                			window.location.href = "${ctx}/sys/role/listRole";
	                		} else {
	                			result = false;
	                			alert(data.error);
	                		}
	                	},
	    			},"json");
				}
				return false;
				
			}
			//$("#sysProAddForm").validationEngine();
			
		</script>
	</body>


</html>